package com.ocom.webapi.controller;


import com.ocom.common.constant.WebApiServiceUrl;
import com.ocom.common.entity.payconfig.EntityFoodstuffPurchase;
import com.ocom.common.request.payconfig.food.GetFoodPurchaseListRequest;
import com.ocom.common.request.payconfig.food.RemoveFoodPurchaseRequest;
import com.ocom.common.resp.Result;
import com.ocom.webapi.feign.PayConfigClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@PreAuthorize("@pms.hasRole('ROLE_WEB')" )
public class FoodPurchaseController {

    @Autowired
    PayConfigClientService payConfigClientService;

    //6.11.1获取采购单列表（FoodPurchase/onShow）
    @PostMapping(WebApiServiceUrl.Url_FoodPurchaseOnShow)
    public Result onShow(@RequestBody GetFoodPurchaseListRequest request) {
        return payConfigClientService.getFoodPurchaseList(request);
    }

    //6.11.2删除采购单（FoodPurchase /delete）
    @PostMapping(WebApiServiceUrl.Url_FoodPurchaseDelete)
    public Result delete(@RequestBody RemoveFoodPurchaseRequest request) {
        return payConfigClientService.removeFoodPurchase(request);
    }

    //6.11.3添加采购单（FoodPurchase/add）
    @PostMapping(WebApiServiceUrl.Url_FoodPurchaseAdd)
    public Result add(@RequestBody EntityFoodstuffPurchase request) {
        return payConfigClientService.newFoodPurchase(request);
    }

    //6.11.4修改采购单（FoodPurchase/modify）
    @PostMapping(WebApiServiceUrl.Url_FoodPurchaseModify)
    public Result modify(@RequestBody EntityFoodstuffPurchase request) {
        return payConfigClientService.updateFoodPurchase(request);
    }

}
